#ifndef KERNEL_H
#define KERNEL_H

#include "global.h"

namespace smsrouter {

class KernelPrivate;

class Kernel : public QObject {
  Q_OBJECT
public:
  Kernel();

  ~Kernel();

  static Kernel *instance();

  int getSrcTimeoutErrorCode(quint32 src_session_id,
                             quint32 error_code);

  int getDestTimeoutErrorCode(quint32 dest_session_id,
                              quint32 error_code);

  quint32 authSrcSession(const QString &system_id,
                         const QString &password,
                         quint32 *error_code = 0);

  KernelSettings *settings() const;

  void altRoute(DestDeliverSm *message);

  QList<DestSessionSettings *> getAllDestSessionSettings() const;

  SrcSessionSettings *getSrcSessionSettings(quint32 id) const;

  DestSessionSettings *getDestSessionSettings(quint32 id) const;

  dbmanager::DatabaseManager *dbSettings();

  dbmanager::DatabaseManager *dbDirections();

  dbmanager::DatabaseManager *dbMessages();

  quint32 getKernelId() const;

  quint32 genMessageId();

  smslog::LogLevel getLogLevel() const;

  bool readConfig(QSettings *config);

  void start();

  void stop();

  QString getLastError() const;

signals:

  void stateChanged(State state);

private:

  friend class KernelPrivate;

  KernelPrivate *p;
};

} // namespace smsrouter

#endif // KERNEL_H
